<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<!-- 经纪人排行榜页面 -->
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
				<form id="formId">
						<ul>
							<!-- <li>
								商户或者代理商id：<input type="text" name="merAgentId"/>
							</li>

							<li>
								类型0是用户 1是代理商：<input type="text" name="type"/>
							</li>

							<li>
								总交易金额：<input type="text" name="amount"/>
							</li>

							<li>
								商户或代理商名称：<input type="text" name="name"/>
							</li>

							<li>
								用户或代理商标识：<input type="text" name="departmentCode"/>
							</li>

							<li>
								用户代理商id：<input type="text" name="agentId"/>
							</li>

							<li>
								用户推荐人id或者代理商的父级id：<input type="text" name="parentId"/>
							</li>

							<li>
								用户等级1普通用户2黄金会员3经纪人：<input type="text" name="merchantLevel"/>
							</li>

							<li>
								代理商级别1运营商2城市商务中心3联合创始人4公司：<input type="text" name="agentLevel"/>
							</li>
 -->
							<li class="select-time">
								<label>查询时间： </label>
								<table>
									<tr>
										<td width="50%">
											<input type="text"  class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
										</td>
									</tr>
									<tr height="5"></tr>
									<tr>
										<td width="50%">
											<input type="text"  class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
										</td>
									</tr>
								</table>
							</li>

							<!-- <li>
								预留字段：<input type="text" name="field1"/>
							</li>

							<li>
								预留字段：<input type="text" name="field2"/>
							</li>

							<li>
								预留字段：<input type="text" name="field3"/>
							</li>

							<li>
								预留字段：<input type="text" name="field4"/>
							</li>

							<li>
								预留字段：<input type="text" name="field5"/>
							</li>

							<li>
								预留字段：<input type="text" name="field6"/>
							</li>

							<li>
								预留字段：<input type="text" name="field7"/>
							</li>

							<li>
								预留字段：<input type="text" name="field8"/>
							</li>

							<li>
								预留字段：<input type="text" name="field9"/>
							</li>

							<li>
								预留字段：<input type="text" name="field10"/>
							</li>-->
						</ul>
						<table>
							<tr height="5"></tr>
							<tr>
								<td style="width: 30%">
									<a class="btn btn-primary btn-rounded btn-sm" onclick="searchSort()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								</td>
								<td style="width: 30%">
									<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</td>
							</tr>
							<tr></tr>
						</table>
				</form>
		<!-- 	
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:merchantAgentAmount:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:merchantAgentAmount:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:merchantAgentAmount:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:merchantAgentAmount:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div> -->
			<br>
			<table id="msg_table">
				<tr >
					<td  style="background-color: yellow;"><strong>数据加载中,请耐心等待......</strong></td>
				</tr>
				<tr></tr>
			</table>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
				<br>
				<table id="sort_table" style="width: 80%"  border="1">
				</table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:merchantAgentAmount:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:merchantAgentAmount:remove')}]];
        $(function() {
        	$("#msg_table").hide();
        });
        function init(){
        	$("#msg_table").show();
        		$.ajax({
    				url : ctx + "system/hatchetMerchantForDLS/sortJJR", //经纪人排名
    				dataType : "json",
    				type : "POST",
    				
    				async : true,
    				success : function(re) {
    					$("#msg_table").hide();
    					var str = "";
    					 str += "<tr >";
    					 str += "<td align='center'><strong>用户排名</strong></td>";
    					 str += "<td align='center'><strong>用户名称</strong></td>";
    					 if(!isPhone()){
    						 str += "<td align='center'><strong>用户编号</strong></td>";
    	   					 str += "<td align='center'><strong>用户手机</strong></td>";
    					 }
    					 str += "<td align='center'><strong>用户收益(元)</strong></td>";
    					 str += "</tr>";
    					
    					$.each(re, function(i,v) {
    					str += "<tr>";
    					str += "<td  align='center'>"+(i+1)+"</td>";	
    					str += "<td  align='center'>"+v.merchantCnName+"</td>";	
    					if(!isPhone()){
    						 str += "<td  align='center'>"+v.merchantNo+"</td>";	
        					str += "<td  align='center'>"+v.phone+"</td>";	
    					}
    					
    					str += "<td  align='center'>"+v.sumMoney+"</td>";	
    					str += "</tr>"
    					});
    					$("#sort_table").html(str);
    				}
    			});
        	} 
        
       		 function searchSort(){
       			$("#sort_table").html("");
       			$("#msg_table").show();
        		$.ajax({
    				url : ctx + "system/hatchetMerchantForDLS/sortJJR", //经纪人排名
    				dataType : "json",
    				type : "POST",
    				data:{
    					"startTime":$("#startTime").val(),
    					"endTime":$("#endTime").val()
    				},
    				async : true,
    				success : function(re) {
    					$("#msg_table").hide();
    					var str = "";
    					str += "<tr>";
	   					 str += "<td align='center'><strong>用户排名</strong></td>";
	   					 str += "<td align='center'><strong>用户名称</strong></td>";
	   					 if(!isPhone()){
    						 str += "<td align='center'><strong>用户编号</strong></td>";
    	   					 str += "<td align='center'><strong>用户手机</strong></td>";
    					 }
	   					 str += "<td align='center'><strong>用户收益(元)</strong></td>";
	   					 str += "</tr>";
    					$.each(re, function(i,v) {
    					str += "<tr>";
    					str += "<td  align='center'>"+(i+1)+"</td>";	
    					str += "<td  align='center'>"+v.merchantCnName+"</td>";	
    					 if(!isPhone()){
    						 str += "<td  align='center'>"+v.merchantNo+"</td>";	
         					str += "<td  align='center'>"+v.phone+"</td>";	
    					 }
    					str += "<td  align='center'>"+v.sumMoney+"</td>";	
    					str += "</tr>"
    					});
    					$("#sort_table").html(str);
    				}
    			});
        	}
       	//判断当前浏览器是否为手机 
       	function isPhone(){
	       	 var sUserAgent = navigator.userAgent.toLowerCase();  
	       	 var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";   
	       	 var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";       
	       	 var bIsMidp = sUserAgent.match(/midp/i) == "midp"; 
	       	 var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; 
	       	 var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";    
	       	 var bIsAndroid = sUserAgent.match(/android/i) == "android";  
	       	 var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";  
	       	 var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";        
	       	 if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { 
	       		 return true;//是手机
	     	   } else {  
	     		return false; //是pc
	     	   }
       	}	 
    </script>
</body>
</html>